package com.recruit.wechat.serviceImpl;
import com.recruit.wechat.controller.helper.$;
import com.recruit.wechat.controller.model.ApiResultModel;

import com.recruit.wechat.bean.WechatPositionCollection;
import com.recruit.wechat.mapper.WechatPositionCollectionMapper;
import com.recruit.wechat.service.WechatPositionCollectionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.recruit.wechat.bean.result.ResultPage;

import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 肖守凯
 * @since 2020-08-24
 */
@Service
public class WechatPositionCollectionServiceImpl extends ServiceImpl<WechatPositionCollectionMapper, WechatPositionCollection> implements WechatPositionCollectionService {
    /** 添加WechatPositionCollection
     * @param wechatPositionCollection  前端传进的参数
     * @return 返回统一信息
     */
    @Override
    public ApiResultModel addWechatPositionCollection(WechatPositionCollection wechatPositionCollection  ) {
           if(this.save(wechatPositionCollection )){
               return $.success();
           }else{
                return $.error("添加失败");
           }
    }
    /** 编辑跳转页面的回显数据WechatPositionCollection
     * @param id  前端传进的参数
     * @return 返回实体类
     */
    @Override
    public WechatPositionCollection selectWechatPositionCollectionByIdWechatPositionCollection(Integer id ){


            return baseMapper.getFavorites(id);
    }


    /** 编辑WechatPositionCollection
     * @param wechatPositionCollection  前端传进的参数
     * @return 返回统一信息
     */
    @Override
    public ApiResultModel editWechatPositionCollection(WechatPositionCollection wechatPositionCollection  ) {
           if(this.updateById(wechatPositionCollection )){
               return $.success();
           }else{
                return $.error("编辑失败");
           }
    }
    /** 删除一条WechatPositionCollection
     * @param id  前端传进的ID
     * @return 返回统一信息
     */
    @Override
    public   ApiResultModel delWechatPositionCollection( Integer id  ){
           if(this.removeById(id)){
               return $.success();
           }else{
                return $.error("删除失败");
           }
    }

   /** 分页查询WechatPositionCollection
     * @param page  页码
     * @param limit  查几条
     * @param wechatPositionCollection  前端传进的参数
     * @return 返回统一分页信息
     */
    @Override
    public  ResultPage findWechatPositionCollectionByPage(Integer page, Integer limit,WechatPositionCollection wechatPositionCollection){
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("page", (page - 1) * limit);
        paramMap.put("limit", limit);
        paramMap.put("wechatPositionCollection", wechatPositionCollection);
        List<WechatPositionCollection> list = baseMapper.selectMyPage(paramMap);
        Integer count = baseMapper.countMyPage(paramMap);
        ResultPage<WechatPositionCollection> resultPage = new ResultPage<>();
        resultPage.setCode(0);
        resultPage.setCount(count);
        resultPage.setMsg("成功");
        resultPage.setData(list);
        return resultPage;
    }

    /**
     * 查看收藏职位的 名称和 公司名字
     * @param id
     * @return
     */
    @Override
    public WechatPositionCollection findFavorites(Integer id) {
        return null;
    }
}
